import { Map } from 'immutable'

const app = (state = Map({
  collapsed: localStorage.getItem('collapsed') === 'true'
}), action) => {
  switch (action.type) {
    case 'CHANGE_COLLAPSED':
      localStorage.setItem('collapsed', !state.get('collapsed'))
      return state.set('collapsed', !state.get('collapsed'))
    default:
      return state
  }
}

export default app